<template>
  <div>
    欢迎您！<font v-model="from.teacher">{{teacher.username}}</font>老师
    <p><font style="color: cyan">学生信息录用</font></p>
    <p>学生名字<input type="text" v-model="from.name"></p>
    <p>年龄<input type="text" v-model="from.age"></p>
    <button @click="add">提交</button>
  </div>
</template>

<script>
export default {
  name: "stu",
  data(){
    return{
      teacher:[],
      from:{}
    }
  },
  methods:{
    get_teacher(){
      this.axios.get('teacher/')
        .then(res=>{
          if(res.data.code==200){
            localStorage.getItem('userid')
            this.teacher = res.data.list
          }
        })
    },
    add(){
      this.axios.post('student/',this.from)
        .then(res=>{
          if(res.data.code==200){
            alert('提交成功')
          }else {
            alert('提交失败')
          }
        })
    }
  },
  mounted() {
    this.get_teacher()
  }
}
</script>

<style scoped>

</style>
